#! /usr/bin/python
# encoding=utf-8
# Created by Fenglu Niu on 2025/5/22 15:25
import sqlite3

from sqlmodel import create_engine, Session, SQLModel

import common


def get_engine():
    sqlite_file_name = f'{common.root_path()}/db/gzzz.db'
    sqlite_url = f"sqlite:///{sqlite_file_name}"

    engine = create_engine(sqlite_url, echo=True)
    return engine

def get_session():
    engine = get_engine()
    with Session(engine) as session:
        yield session
def init_db():
    # 创建案件表
    from api import entity
    SQLModel.metadata.create_all(get_engine())

if __name__ == '__main__':
    init_db()
